package com.zi.experttalk.experttalk.Model.service;

import android.content.Context;
import android.util.Log;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;

/**
 * Created by Administrator on 2014/12/10.
 */
public class LocationManager {
    private Context context;
    private LocationClient locationClient = null;
    private BDLocationListener bdLocationListener = null;
    public LocationManager(Context context){
        this.context = context;
    }
    public void getCurrentLocation(Context context){
        locationClient = new LocationClient(context);
        bdLocationListener = new MyLocationListener();
        setLocationOption();
        locationClient.start();
        locationClient.requestLocation();
    }
    private void setLocationOption(){
        LocationClientOption option = new LocationClientOption();
        option.setOpenGps(true);
        option.setIsNeedAddress(true);
        option.setCoorType("bd0911");
        locationClient.setLocOption(option);
    }
    private class MyLocationListener implements BDLocationListener {
        @Override
        public void onReceiveLocation(BDLocation bdLocation) {
            if (bdLocation == null) {
                return;
            }
            Log.d("mapmap",bdLocation.getCity().toString());
        }
    }
}
